import { createRouter, createWebHistory,createWebHashHistory } from 'vue-router'
import nprogress from 'nprogress'

const router = createRouter({
  history: import.meta.env.DEV ? createWebHashHistory() : createWebHistory(),
  routes: [
    {
      path: '/:fileType?',
      name: 'home',
      component: () => import('@manager/views/home/home.vue'),
    },
    {
      path: '/:pathMatch(.*)*',
      name: '404',
      component: () => import('@manager/views/error/404.vue'),
    },
  ],
})
// 路由守卫
router.beforeEach(() => {
  nprogress.start()
  // 如果用户已经登录，或者用户访问的是登录页面，就放行
  // if (!useUserStore().userState.token && to.path !== '/login') return '/login'
})

router.afterEach(() => {
  nprogress.done()
})

export default router
